1. 安装淘宝镜像
1 | $ npm install -g cnpm --registry=https://registry.npm.taobao.org |
2. 使用 create-react-app 快速构建 React 开发环境
1 | $ cnpm install -g create-react-app |
3. 使用外部React组件
test.js1
2
3
4
5
6
7import React, { Component } from 'react';
class Test extends Component{
render () {
return (<div>1234</div>)
}
}
export default Test;
index.js1
2
3
4
5
6
7
8
9import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import Test from './test';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<Test />, document.getElementById('root'));
registerServiceWorker();